package com.baizhi.realm;

import com.baizhi.dao.AdminDao;
import com.baizhi.entity.Admin;
import org.apache.shiro.authc.*;
import org.apache.shiro.realm.AuthenticatingRealm;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpSession;

public class AuthenRealm extends AuthenticatingRealm {
    @Autowired
    private AdminDao adminDao;

    @Autowired
    private HttpSession session;

    /**
     * 查询数据库数据
     * @param token
     * @return
     * @throws AuthenticationException
     */



    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
     /*   //1.获取token中的数据
        UsernamePasswordToken token1=(UsernamePasswordToken) token;
        String username = token1.getUsername();

        //2.根据用户名 查询数据库
        Admin admin = adminDao.selectByUserName(username);

        //3.查询结果不为null 封装info
        if(admin!=null){
            session.setAttribute("a",admin);
            return new SimpleAuthenticationInfo(admin.getUserName(),admin.getPassword(),this.getName());
        }


*/
        return null;



    }
}
